package cn.edu.sjtu.stap.sdg.internal;

import java.util.*;
import cn.edu.sjtu.stap.cfg.internal.*;
import cn.edu.sjtu.stap.output.*;

public aspect SdgBuildTiming {
    public pointcut mainMethodPc() : call(* ResultOutput.writeSdg(..));

    public pointcut buildSdgPc() : call(* buildInterSdg(..));

    private long interSdgTime = 0;

    private Stack<Long> time = new Stack<Long>();

    before() : buildSdgPc() {
        interSdgTime = System.currentTimeMillis();
    }

    after() : buildSdgPc() {
        interSdgTime = System.currentTimeMillis() - interSdgTime;
        interSdgTime *= 1000000; 
    }

    after() : mainMethodPc() {
        try {
            Initializer.out.writeLine("");
//            Initializer.out.writeLine("ASDGT run: " + interSdgTime + " ms.");
        } catch (Exception e) {
            System.err.println("Error writing time!");
            e.printStackTrace();
        }
    }
}
